import React, {Component} from 'react';
import {Provider, connect} from 'react-redux';
import {View, NativeModules, Alert} from 'react-native';
import {createReduxContainer} from 'react-navigation-redux-helpers';
// import Orientation from 'react-native-orientation';
import 'react-native-program-stylesheet';
import {setToastMsg} from 'actions/index';
import {GToast, Loading, Update} from 'components/index';

import store from 'store/index';

import RootNavigator from 'router/index';
import * as wechat from 'react-native-wechat';
import FetchTest from './test/FetchTest';

const Navigation = createReduxContainer(RootNavigator, 'root');

const mapStateToProps = state => ({
  state: state.nav,
});

const AppNavigator = connect(mapStateToProps)(Navigation);

global.store = store;

export default class Root extends Component {
  componentDidMount() {
    wechat.registerApp('wx2e59619c5eda6dc5');
    // Orientation.lockToPortrait();
  }

  render() {
    return (
      <Provider store={store}>
        <View style={{flex: 1}}>
          <AppNavigator />
          <Loading />
          <GToast />
          <Update />
        </View>
      </Provider>
    );
  }
}
